package com.woniu.woniu_bx.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniu.woniu_bx.pojo.Manager;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.jdbc.SQL;

import java.util.List;

/**
 * @Description 管理员
 * @Author zhangjin
 * @Date 2022/8/27 16:10
 */
public interface ManagerMapper extends BaseMapper<Manager> {
    // 查询指定账号名称的数量
    @Select("select count(*) from bx_manager where account=#{account}")
    int getManagerNumByAccount(String account);

    //逻辑删除
    @Update("update bx_manager set status = 'N' where id =#{id}")
    void logicDel(int id);

    @Select("select * from bx_manager where account=#{account}")
    @Results(id = "managerMap", value = {
            @Result(column = "role_id", property = "roleId")
    })
    Manager getManagerByAccountPwd(@Param("account") String account);


    @Select("select m.*,r.name rname from bx_manager m,bx_role r where m.role_id=r.id")
    @Results(id = "aminMap",value = {
            @Result(column = "role_id", property = "roleId"),
            @Result(column = "rname",property = "roleName")
    })
    List<Manager> getAllManagers();

}
